<?php
/**
 * @file
 * Facebook's JavaScript for publishing to a user's wall.
 *
 * Usage:
 *  - A JavaScript block that wants to publish to a user's wall should
 *    include/require this page once and only once. (Note: There may be many
 *    JavaScript blocks in a page. Thus, it is more correct to use
 *    'include'/'require' rather than 'include_once'/'require_once'.)
 *  - This page must be either embedded within a JavaScript block or placed
 *    within the '<script></script>' tags if it is used on its own.
 *  - The JavaScript block in which this page is inserted must be executed.
 *    (E.g. If this page is inserted within a JavaScript function, that
 *    JavaScript function must be called to publish to a user's wall.)
 *  - The 'FBJS Feature Loader' must be loaded before executing this JavaScript.
 *
 * Parameter(s):
 *  - $PATH_COMMON : Relative path from the calling page to the 'common'
 *                   directory (e.g. '../common/').
 *
 * Global variable(s) set:
 *  - None.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - h_facebook.php
 */

// header file(s) ==============================================================
require_once $PATH_COMMON . "php/h_facebook.php";


// implementation ==============================================================
// JavaScript Parameter(s) -----------------------------------------------------
/**
 *  - fb_pub_user_message   : User message.
 *  - fb_pub_attachments    : Attachments.
 *  - fb_pub_action_links   : Action links.
 *  - fb_pub_target_user_id : Target users' Facebook 'User ID'.
 *  - fb_pub_message_prompt : Message Prompt.
 *  - fb_pub_callback       : Callback function.
 *  - fb_pub_auto_publish   : Automatic publishing. (Only applicable if the
 *                            canvas user has granted the 'publish_stream'
 *                            extended permission).
 */
?>
FB_RequireFeatures(
  ["Connect"],
  function() {
    FB.Facebook.init(
      "<?php echo FB_APP_KEY ?>",
      "<?php echo FB_JS_XDOMAIN_RECEIVER ?>"
    );
    FB.Connect.streamPublish(
      fb_pub_user_message,
      fb_pub_attachments,
      fb_pub_action_links,
      fb_pub_target_user_id,
      fb_pub_message_prompt,
      fb_pub_callback,
      fb_pub_auto_publish
    );
  }
);
